import { ProCard, ProColumns, ProForm, ProFormRadio, ProFormText, ProTable } from "@ant-design/pro-components"
import { Col, Row, Tag, Tree } from "antd";
import _default from "antd/es/time-picker";

const App:React.FC=()=>{

     interface DataType{
            code?:string,name?:string,degree?:string,status?:string,invstd?:string,
            ddate?:string,dep_name?:string,place?:string,type?:string,vendor?:string,
         };
    
         const columns:ProColumns<DataType>[]=[
            {dataIndex:'code',title:'编码'},{dataIndex:'name',title:'名称'},
            {dataIndex:'invstd',title:'规格型号'},{dataIndex:'vendor',title:'厂商'},
            {dataIndex:'degree',title:'等级'},{dataIndex:'dep_name',title:'归属部门'},
            {dataIndex:'place',title:'位置'},
             {dataIndex:'type',title:'来源'},
             {dataIndex:'ddate',title:'安装时间'},
            {dataIndex:'status',title:'状态',
                render:(text)=><Tag  style={{width:80}} color={text=='在用'?'red':text=='闲置'?'blue':'red'}>{text}</Tag>
            },
         ];
    
         const tdata:DataType[]=[
            {code:'AC01001',name:'XX数控机床',type:'自购',status:'在用',degree:'A级',
             invstd:'JC56001',vendor:'广州新创科技',dep_name:'一车间',place:'一楼B1位',ddate:'2023-03-10',},
             {code:'AC01002',name:'XX数控机床',type:'自购',status:'在用',degree:'A级',
                invstd:'JC56001',vendor:'广州新创科技',dep_name:'一车间',place:'一楼B2位',ddate:'2023-03-10',},
                {code:'AC01003',name:'XX数控机床',type:'自购',status:'在用',degree:'A级',
                    invstd:'JC56001',vendor:'广州新创科技',dep_name:'一车间',place:'一楼B3位',ddate:'2023-03-10',},
                    {code:'KVC56009',name:'齿轮铣床',type:'自购',status:'闲置',degree:'B级',
                        invstd:'JM-226P6',vendor:'青岛第一机床厂',dep_name:'一车间',place:'二楼B位',ddate:'2023-03-10',},
                        {code:'KVC56009',name:'齿轮铣床',type:'自购',status:'闲置',degree:'B级',
                            invstd:'JM-226P6',vendor:'青岛第一机床厂',dep_name:'一车间',place:'二楼B位',ddate:'2023-03-10',},
                            {code:'YS00291',name:'中型叉车',type:'租赁',status:'故障',degree:'C级',
                                invstd:'HC29003',vendor:'杭州叉车租赁',dep_name:'储运部',place:'储运区',ddate:'2022-03-01',},
         ];

        

         const treeNode=[
            {
                key:'0',
                title:'设备分类',
                children:[
                    {
                        key:'01',
                        title:'生产设备',
                        children:[
                            {key:'0101',title:'数控机床'},
                            {key:'0102',title:'磨床'},
                            {key:'0103',title:'装配'},
                            {key:'0104',title:'喷漆'},
                        ],
                    },
                    {
                        key:'02',
                        title:'辅助设备',
                        children:[
                            {key:'0201',title:'机械手'},
                            {key:'0202',title:'传送带'},
                            {key:'0202',title:'叉车'},
                        ],
                    },
                    {
                        key:'03',
                        title:'工装夹具',
                        children:[
                            {key:'0301',title:'刀具'},
                            {key:'0302',title:'模具'},
                            {key:'0303',title:'其他'},
                        ],
                    },
                    {
                        key:'04',
                        title:'房屋建筑',
                        children:[],
                    },
                ]
            },
          ];

    return <>
       <ProCard title='设备台账' style={{height:700}} 
       >
        <Row gutter={8}>
            <Col span={6}>
                <ProCard bordered style={{height:600}}>
                 <Tree treeData={treeNode} defaultExpandAll/>
                 </ProCard>
            </Col>
            <Col span={18}>
               <ProCard bordered  style={{height:600}}  >
                     <ProTable<DataType>
                        search={false}
                        options={false}
                        columns={columns}
                        dataSource={tdata}
                        />
            </ProCard>
            </Col>
        </Row>
       </ProCard>
    </>;
};

export default App;